package pri.zey.custom.tools;/**
 * Created by Administrator on 2016/3/16.
 */

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * Toast工具
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class TToast {

    private static TToast mToast;
    private Context mContext;
    private Toast toast;

    private TToast(Context mContext){
        this.mContext = mContext;
    }

    public TToast getInstance(Context mContext){
        if(mToast == null){
            mToast = new TToast(mContext);
        }
        return mToast;
    }

    // 显示提示信息（Toast）
    public void Toastl(String tip) {
        if (toast == null) {
            toast = Toast.makeText(mContext, tip, Toast.LENGTH_LONG);
        } else {
            toast.setText(tip);
        }
        toast.setGravity(Gravity.TOP, 0, 80);
        toast.show();
    }

    public void Toasts(String tip) {
        if (toast == null) {
            toast = Toast.makeText(mContext, tip, Toast.LENGTH_SHORT);
        } else {
            toast.setText(tip);
        }
        toast.setGravity(Gravity.TOP, 0, 80);
        toast.show();
    }

    public void Toasts(int resId) {
        if (toast == null) {
            toast = Toast.makeText(mContext, resId, Toast.LENGTH_SHORT);
        } else {
            toast.setText(resId);
        }
        toast.setGravity(Gravity.TOP, 0, 80);
        toast.show();
    }

    public void Toastl(int resId) {
        if (toast == null) {
            toast = Toast.makeText(mContext, resId, Toast.LENGTH_LONG);
        } else {
            toast.setText(resId);
        }
        toast.setGravity(Gravity.TOP, 0, 80);
        toast.show();
    }
}
